<template>
  <div>
    <el-card>
      <span class="title-icon">扫描换单</span>
    </el-card>
    <el-card :span="24">
      <el-row>
        <el-col :span="12">
          <el-input
            size="medium"
            clearable
            autofocus
            v-model="labelNo"
            placeholder="请输入面单号"
            @keyup.enter.native="changeLabel"
            @on-blur="validateAlphabet(labelNo)"
          ></el-input>
        </el-col>
        <el-col :span="1">
          &nbsp;
        </el-col>
        <el-col :span="4">
          <el-button type="primary" size="medium" @click="changeLabel"
            >执行换单</el-button
          >
        </el-col>
      </el-row>
    </el-card>
    <el-card>
      <span class="title-icon">换单结果</span>
    </el-card>
  </div>
</template>
<script>
import { ajax } from "@/store/yg/common/utils";
import axios from "axios";
import * as constant from "@/store/yg/common/constant";

export default {
  components: {},
  props: [],
  data() {
    return {
      labelNo: ""
    };
  },
  methods: {
    changeLabel() {
      if ("" === this.labelNo) {
        return;
      }
      var data = {};
      data["labelNo"] = this.labelNo;
      console.log(data);
      this.labelNo = "";
      ajax("doChangeLabel", data).then(
        res => {
          this.row = res;
          console.log(res);
        },
        error => {
          console.log(error);
        }
      );
    }
  },
  watch: {
    labelNo: function() {
      this.labelNo = this.labelNo.replace(/[^A-Za-z0-9]/g, "");
    }
  }
};
</script>
